{
 "cells": [
  {
   "cell_type": "markdown",
   "source": [
    "# Set Up\n",
    "\n",
    "1. click “Edit” -> \"Notebook Settings\" -> \"Hardware accelerator, GPU\" -> Save\n",
    "<img src=\"https://z3.ax1x.com/2021/03/30/ciQWWV.png\">\n",
    "\n",
    "2. Click the folder icon on the left, upload your video file, and copy the uploaded video path\n",
    "\n",
    "<img src=\"https://z3.ax1x.com/2021/03/30/cilvhq.png\">\n",
    "\n",
    "3. Run the code, enter the pasted video path\n",
    "\n",
    "\n"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "_jPi_FBwyZyr"
   },
   "source": [
    "check whether GPU works"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "eHPHc_Bheo-j"
   },
   "outputs": [],
   "source": [
    "!nvidia-smi"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "TkQKKGKZkkT2"
   },
   "outputs": [],
   "source": [
    "!nvcc -V"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "_85O6zgPyhto"
   },
   "source": [
    "# Install Dependencies"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "ICeq0T1FeqjT"
   },
   "outputs": [],
   "source": [
    "!git clone --depth=1 https://github.com/YaoFANGUK/video-subtitle-extractor.git"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "GHutEWynkMKR"
   },
   "outputs": [],
   "source": [
    "cd video-subtitle-extractor"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "ynJydzo1kMKR"
   },
   "outputs": [],
   "source": [
    "!pip install -r requirements_gpu.txt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [
    "!echo -e '[DEFAULT]\\nInterface = English\\nLanguage = en\\nMode = fast' > /content/video-subtitle-extractor/settings.ini"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "3-GdvmaGl-aF"
   },
   "outputs": [],
   "source": [
    "!pip install paddlepaddle-gpu==2.4.2.post117 -f https://www.paddlepaddle.org.cn/whl/linux/mkl/avx/stable.html"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "SGb0i3tPyw9Q"
   },
   "source": [
    "# Run"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Here is an example:\n",
    "\n",
    "input video path: /content/video-subtitle-extractor/test/test_en.mp4\n",
    "\n",
    "input subtitle area: 612 717 90 1191"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "B2MPjMOOgGbD"
   },
   "outputs": [],
   "source": [
    "!python ./backend/main.py"
   ]
  }
 ],
 "metadata": {
  "accelerator": "GPU",
  "colab": {
   "collapsed_sections": [],
   "name": "video-subtitle-extractor.ipynb",
   "provenance": []
  },
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
